package es.cea;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import es.cea.agendatelefonica.ContactoTel;

@WebListener
public class AgendaContextoListener implements ServletContextListener {

 
    public AgendaContextoListener() {
       
    }


    public void contextInitialized(ServletContextEvent arg0) {
    	
    	
    	List<ContactoTel> contactos=new ArrayList<ContactoTel>();
		contactos.add(new ContactoTel(1,"Dario", "123456"));
		contactos.add(new ContactoTel(2,"Maria", "7891011"));
		contactos.add(new ContactoTel(3,"Joselito", "12131415"));
		contactos.add(new ContactoTel(4,"Ruben", "23232323"));
		contactos.add(new ContactoTel(5,"pepe", "24652323"));
		
		arg0.getServletContext().setAttribute("contactos", contactos);
		System.out.println("Creada la aplicacion agenda");
		
    }

    public void contextDestroyed(ServletContextEvent arg0) {
        
    }
	
}
